<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Array</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Array</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/lib/linguistics/en_rb.html">
                lib/linguistics/en.rb
                </a>
        &nbsp;(<a href="http://deveiate.org/projects/Linguistics/browser/trunk/lib/linguistics/en.rb"><acronym title="Concurrent Versioning System">CVS</acronym></a>)
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Add the <a href="Array.html#M000001">#separate</a> and <a
href="Array.html#M000001">#separate</a>! methods to <a
href="Array.html">Array</a>.
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000001">separate</a>&nbsp;&nbsp;
      <a href="#M000002">separate!</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000001" class="method-detail">
        <a name="M000001"></a>

        <div class="method-heading">
          <a href="#M000001" class="method-signature">
          <span class="method-name">separate</span><span class="method-args">( value=:__no_arg__, &amp;block )</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns a new <a href="Array.html">Array</a> that has had a new member
inserted between all of the current ones. The value used is the given
<tt>value</tt> argument unless a block is given, in which case the block is
called once for each pair of the <a href="Array.html">Array</a>, and the
return value is used as the separator.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000001-source">
<pre>
      <span class="ruby-comment cmt"># File lib/linguistics/en.rb, line 1728</span>
1728:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">separate</span>( <span class="ruby-identifier">value</span>=<span class="ruby-identifier">:__no_arg__</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
1729:         <span class="ruby-identifier">ary</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">dup</span>
1730:         <span class="ruby-identifier">ary</span>.<span class="ruby-identifier">separate!</span>( <span class="ruby-identifier">value</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
1731:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">ary</span>
1732:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000002" class="method-detail">
        <a name="M000002"></a>

        <div class="method-heading">
          <a href="#M000002" class="method-signature">
          <span class="method-name">separate!</span><span class="method-args">( value=:__no_arg__ ) {|self[i-1,2]| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
The same as <a href="Array.html#M000001">#separate</a>, but modifies the <a
href="Array.html">Array</a> in place.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000002-source">
<pre>
      <span class="ruby-comment cmt"># File lib/linguistics/en.rb, line 1735</span>
1735:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">separate!</span>( <span class="ruby-identifier">value</span>=<span class="ruby-identifier">:__no_arg__</span> )
1736:         <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-value str">&quot;wrong number of arguments: (0 for 1)&quot;</span> <span class="ruby-keyword kw">if</span>
1737:             <span class="ruby-identifier">value</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:__no_arg__</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">block_given?</span>
1738: 
1739:         (<span class="ruby-value">1</span><span class="ruby-operator">..</span>( (<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">*</span> <span class="ruby-value">2</span>) <span class="ruby-operator">-</span> <span class="ruby-value">2</span> )).<span class="ruby-identifier">step</span>(<span class="ruby-value">2</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
1740:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
1741:                 <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">insert</span>( <span class="ruby-identifier">i</span>, <span class="ruby-keyword kw">yield</span>(<span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>,<span class="ruby-value">2</span>]) )
1742:             <span class="ruby-keyword kw">else</span>
1743:                 <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">insert</span>( <span class="ruby-identifier">i</span>, <span class="ruby-identifier">value</span> )
1744:             <span class="ruby-keyword kw">end</span>
1745:         <span class="ruby-keyword kw">end</span>
1746:         <span class="ruby-keyword kw">self</span>
1747:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>